//
//  MPVisitorTableViewController.swift
//  MPSinaWeibo
//
//  Created by DaVinci on 16/4/8.
//  Copyright © 2016年 DaVinci. All rights reserved.
//

import UIKit

class MPVisitorTableViewController: UITableViewController,MPVisitorViewDelegate {

    var VisitorView: MPVisitorView?
    
    
    //MARK:用户是否登录
    
    var userLogin = MPUserAccountViewModel.sharedAccountViewModel.userLogin
//      var userLogin = false
    
    override func loadView() {
        
        userLogin ? super.loadView() : prepareForVistorView()
    }
   
    private func prepareForVistorView(){
    
        VisitorView = MPVisitorView()
        
        VisitorView?.delegate = self
        
        
        view = VisitorView
        
        VisitorView?.backgroundColor = UIColor(red: 237/255.0, green: 237/255.0, blue: 237/255.0, alpha: 1.0)
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_friendsearch", title: nil, target: self, action: "loginBtnWillClick")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "rigisterBtnWillClick")
    }
    
    
    
    
    //MARK:实现Visitor按钮点击的代理方法
    
    func rigisterBtnWillClick() {
        
        
    }
    
    func loginBtnWillClick() {
        
         let web = MPOAuthController()
        
        let nav = UINavigationController(rootViewController: web)
        presentViewController(nav, animated: true, completion: nil)
    }

}
